<template>
  <div class="wrap">
    <div class="w-title">
      我收藏的
    </div>
    <a-tabs>
      <a-tab-pane tab="全部" key="1"></a-tab-pane>
    </a-tabs>
    <a-list :grid="{ gutter: 16, column: 6 }" :dataSource="list">
      <a-list-item slot="renderItem" slot-scope="item" class="box" @click="onJump(item)">
        <img :src="item.game_icon" alt srcset />
        <div>{{item.game_title}}</div>
        <div>￥{{item.game_price}}</div>
      </a-list-item>
    </a-list>
    <div class="pagination">
      <a-pagination showQuickJumper v-model="page" :defaultPageSize="24" :total="total" @change="onChange" />
    </div>
  </div>
</template>

<script>
import { MY_COLLECT } from "../server";
export default {
  layout: "main",
  data() {
    return {
      list: [],
      total: 0,
      page: 1
    };
  },
  created() {
    this.getCollect();
  },
  methods: {
    onJump(v) {
      this.$router.push({
        name: `game-list-msg`,
        params: {
          list: v.list_id,
          msg: v.game_id
        }
      });
    },
    getCollect() {
      MY_COLLECT({ page: this.page, pageshow: 24 }).then(res => {
        if (res) {
          this.list = res.data.list;
          this.total = res.data.count;
        } else {
          this.list = [];
        }
      });
    },
    onChange(page) {
      this.page = page;
      this.getCollect();
    }
  }
};
</script>
<style lang="less" scoped>
.wrap {
  border: 3px solid #0084ff;
  border-radius: 6px;
  padding: 10px;
  .w-title {
    height: 40px;
    line-height: 40px;
    background: #0084ff;
    color: #fff;
    margin-bottom: 20px;
    border-radius: 6px;
    font-size: 18px;
    font-weight: bold;
    padding-left: 16px;
  }
}
.box {
  cursor: pointer;
  img {
    width: 156px;
    height: 156px;
  }
  div:nth-child(2) {
    width: 100%;
    height: 26px;
    line-height: 26px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  div:nth-child(3) {
    color: #0084ff;
  }
}
.pagination {
  margin: 70px auto 60px;
  text-align: center;
}
</style>